Skip to content

feat(metrics): implement metric reader metrics#4970

Merged
lzchen merged 12 commits intoopen-telemetry:mainfrom
anuraaga:metrics-reader-metrics
Mar 19, 2026
Merged

feat(metrics): implement metric reader metrics#4970
lzchen merged 12 commits intoopen-telemetry:mainfrom
anuraaga:metrics-reader-metrics

Conversation

@anuraaga
Copy link
Copy Markdown
Contributor

@anuraaga anuraaga commented Mar 12, 2026

Description

I am helping to implement SDK internal metrics

https://opentelemetry.io/docs/specs/semconv/otel/sdk-metrics/

This implements the metric for metric reader collections, namely otel.sdk.exporter.operation.duration.

Similar PR in Java: open-telemetry/opentelemetry-java#8038
Similar PR in JS: open-telemetry/opentelemetry-js#6449

/cc @xrmx to help with review

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Unit tests

Does This PR Require a Contrib Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

@anuraaga anuraaga requested a review from a team as a code owner March 12, 2026 05:06
@aabmass aabmass moved this to Easy to review / merge / close in Python PR digest Mar 12, 2026
@anuraaga
Copy link
Copy Markdown
Contributor Author

Sent open-telemetry/opentelemetry-python-contrib#4332 to make genai test only read its scope

@anuraaga anuraaga force-pushed the metrics-reader-metrics branch from 120c3db to 3c70e2a Compare March 13, 2026 05:27
Comment thread opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/export/__init__.py Outdated
Comment thread opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/export/__init__.py Outdated
@lzchen
Copy link
Copy Markdown
Contributor

lzchen commented Mar 16, 2026

@anuraaga

Thanks for your contribution! Could you update the title + description to include that this PR covers specifically implementing the otel.sdk.exporter.operation.duration metric for the metric reader.

Copy link
Copy Markdown
Contributor Author

@anuraaga anuraaga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @lzchen - I updated the description for more clarity but left the title as is since the intent of the PR is to implement all the metric reader metrics. There just happens to only be one.

Comment thread opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/export/__init__.py Outdated
@lzchen lzchen merged commit 57821e9 into open-telemetry:main Mar 19, 2026
506 checks passed
@github-project-automation github-project-automation Bot moved this from Easy to review / merge / close to Done in Python PR digest Mar 19, 2026
Vitexus pushed a commit to Vitexus/opentelemetry-python that referenced this pull request Apr 30, 2026
nicoloboschi pushed a commit to vectorize-io/hindsight that referenced this pull request May 4, 2026
…exporter} floors so PrometheusMetricReader 0.62b1 doesn't crash startup (#1373)

opentelemetry-exporter-prometheus 0.62b1 calls
MetricReader.__init__(otel_component_type=…), a kwarg that opentelemetry-sdk
introduced only in v1.41.0 (open-telemetry/opentelemetry-python#4970).

The previous `opentelemetry-{api,sdk}>=1.20.0` /
`opentelemetry-{instrumentation,exporter,semantic-conventions}>=0.41b0` /
`opentelemetry-exporter-otlp-proto-http>=1.20.0` floors let pip resolve a
recent exporter-prometheus against an older sdk (e.g. 1.39.x cached in a
lockfile), so on hindsight-api startup metric initialisation explodes with
"MetricReader.__init__() got an unexpected keyword argument
'otel_component_type'.  Metrics will be disabled (using no-op collector)."
Functionally hindsight stays up but /metrics is silently empty.

Bumping all six otel pins to the matching 1.41.0 / 0.62b1 floor keeps
pip's resolver consistent across the otel ecosystem and removes the
mismatch that produces the warning.

Closes #1372
liling pushed a commit to liling/hindsight that referenced this pull request May 5, 2026
…exporter} floors so PrometheusMetricReader 0.62b1 doesn't crash startup (vectorize-io#1373)

opentelemetry-exporter-prometheus 0.62b1 calls
MetricReader.__init__(otel_component_type=…), a kwarg that opentelemetry-sdk
introduced only in v1.41.0 (open-telemetry/opentelemetry-python#4970).

The previous `opentelemetry-{api,sdk}>=1.20.0` /
`opentelemetry-{instrumentation,exporter,semantic-conventions}>=0.41b0` /
`opentelemetry-exporter-otlp-proto-http>=1.20.0` floors let pip resolve a
recent exporter-prometheus against an older sdk (e.g. 1.39.x cached in a
lockfile), so on hindsight-api startup metric initialisation explodes with
"MetricReader.__init__() got an unexpected keyword argument
'otel_component_type'.  Metrics will be disabled (using no-op collector)."
Functionally hindsight stays up but /metrics is silently empty.

Bumping all six otel pins to the matching 1.41.0 / 0.62b1 floor keeps
pip's resolver consistent across the otel ecosystem and removes the
mismatch that produces the warning.

Closes vectorize-io#1372
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants